/*
 * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/* ScriptData
SDName: Zangarmarsh
SD%Complete: 100
SDComment: Quest support: 9785, 9803, 10009, 9752. Mark Of ... buffs.
SDCategory: Zangarmarsh
EndScriptData */

/* ContentData
npcs_ashyen_and_keleth
npc_cooshcoosh
npc_elder_kuruti
npc_mortog_steamhead
npc_kayra_longmane
EndContentData */

#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedEscortAI.h"
#include "ObjectMgr.h"
#include "ScriptedGossip.h"

/*######
## npcs_ashyen_and_keleth
######*/

#define GOSSIP_ITEM_BLESS_ASH     "Grant me your mark, wise ancient."
#define GOSSIP_ITEM_BLESS_KEL     "Grant me your mark, mighty ancient."
#define GOSSIP_REWARD_BLESS       -1000207
//#define TEXT_BLESSINGS        "<You need higher standing with Cenarion Expedition to recive a blessing.>"





/*######
## npc_cooshcoosh
######*/

#define GOSSIP_COOSH            "I have been sent by Sal'salabim to collect a debt that you owe. Pay up or I'm going to hurt you."

#define SPELL_LIGHTNING_BOLT    9532
#define SPELL_LIGHTNING_SHIELD  12550

#define SAY_COOSH				-1910148








/*######
## npc_elder_kuruti
######*/

enum KurutiSpells
{
	SPELL_LIGHTNINGSHIELD = 12550,
	SPELL_HEALINGWAVE = 11986,
	SPELL_CHAINLIGHTNING = 12058
};

#define GOSSIP_ITEM_KUR1 "Offer treat"
#define GOSSIP_ITEM_KUR2 "Im a messenger for Draenei"
#define GOSSIP_ITEM_KUR3 "Get message"









/*######
## npc_mortog_steamhead
######*/





/*######
## npc_kayra_longmane
######*/

enum eKayra
{
    SAY_START           = -1000343,
    SAY_AMBUSH1         = -1000344,
    SAY_PROGRESS        = -1000345,
    SAY_AMBUSH2         = -1000346,
    SAY_END             = -1000347,

    QUEST_ESCAPE_FROM   = 9752,
    NPC_SLAVEBINDER     = 18042
};







/*######
## npc_timothy_daniels
######*/

#define GOSSIP_TIMOTHY_DANIELS_ITEM1    "Specialist, eh? Just what kind of specialist are you, anyway?"
#define GOSSIP_TEXT_BROWSE_POISONS      "Let me browse your reagents and poison supplies."

enum eTimothy
{
    GOSSIP_TEXTID_TIMOTHY_DANIELS1      = 9239
};



;

/*######
## npc_baby_murloc
######*/

enum
{
    NPC_PURPLE_MURLOC          = 15357,
    NPC_GREEN_MURLOC           = 15360,
    NPC_BLUE_MURLOC            = 15356,
    NPC_PINK_MURLOC            = 15359,
    NPC_ORANGE_MURLOC          = 15361,
    NPC_CREDIT                 = 18152,

    QUEST_HAVE_YOU_EVER        = 9816,

    SPELL_SING                 = 32041
};

struct Pos
{
    float x, y, z;
};

static Pos M[]=
{
    {1206.926f, 8139.298f, 19.70f},
    {1206.927f, 8158.908f, 19.51f},
    {1220.742f, 8093.757f, 18.120f},
    {1128.926f, 8137.008f, 20.664f},
    {1230.289f, 8156.368f, 18.40f},
    {1216.511f, 8188.199f, 18.70f}
};









enum WrektSlave
{
	SPELL_SHAREDBONDS = 34788,
	SPELL_KICK = 11978,

	SAY_RUN = -1910102,

	NPC_SLAVEDRIVER = 18089,
	NPC_WREKTSLAVE = 18123
};

Position const FleePath = { 555.669f, 7931.552f, 17.374f, 0.0f };





enum DrudgeSlave
{
	NPC_DARKSCRESTSLAVER = 19946,
	NPC_DREGHOODSLAVE = 18122
};

Position const Flee1Path = { -550.226f, 5535.522f, 22.424f, 0.0f };








class npcs_ashyen_and_keleth : public CreatureScript
{
public: 
    npcs_ashyen_and_keleth() : CreatureScript("npcs_ashyen_and_keleth") { }
    

    

    bool OnGossipHello(Player* player, Creature* pCreature) override
    {
        if (player->GetReputationRank(942) > REP_NEUTRAL)
        {
            if (pCreature->GetEntry() == 17900)
                player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_BLESS_ASH, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
            if (pCreature->GetEntry() == 17901)
                player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_BLESS_KEL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
        }
        player->SEND_GOSSIP_MENU(player->GetGossipTextId(pCreature), pCreature->GetGUID());
    
        return true;
    }
    


    bool OnGossipSelect(Player* player, Creature* pCreature, uint32 /*sender*/, uint32 action) override
    {
        if (action == GOSSIP_ACTION_INFO_DEF + 1)
        {
            pCreature->setPowerType(POWER_MANA);
            pCreature->SetMaxPower(POWER_MANA, 200);            //set a "fake" mana value, we can't depend on database doing it in this case
            pCreature->SetPower(POWER_MANA, 200);
    
            if (pCreature->GetEntry() == 17900)                //check which creature we are dealing with
            {
                switch (player->GetReputationRank(942))
                {
                //mark of lore
                case REP_FRIENDLY:
                    pCreature->CastSpell(player, 31808, true);
                    DoScriptText(GOSSIP_REWARD_BLESS, pCreature);
                    break;
                case REP_HONORED:
                    pCreature->CastSpell(player, 31810, true);
                    DoScriptText(GOSSIP_REWARD_BLESS, pCreature);
                    break;
                case REP_REVERED:
                    pCreature->CastSpell(player, 31811, true);
                    DoScriptText(GOSSIP_REWARD_BLESS, pCreature);
                    break;
                case REP_EXALTED:
                    pCreature->CastSpell(player, 31815, true);
                    DoScriptText(GOSSIP_REWARD_BLESS, pCreature);
                    break;
                default:
                    break;
                }
            }
    
            if (pCreature->GetEntry() == 17901)
            {
                switch (player->GetReputationRank(942))         //mark of war
                {
                case REP_FRIENDLY:
                    pCreature->CastSpell(player, 31807, true);
                    DoScriptText(GOSSIP_REWARD_BLESS, pCreature);
                    break;
                case REP_HONORED:
                    pCreature->CastSpell(player, 31812, true);
                    DoScriptText(GOSSIP_REWARD_BLESS, pCreature);
                    break;
                case REP_REVERED:
                    pCreature->CastSpell(player, 31813, true);
                    DoScriptText(GOSSIP_REWARD_BLESS, pCreature);
                    break;
                case REP_EXALTED:
                    pCreature->CastSpell(player, 31814, true);
                    DoScriptText(GOSSIP_REWARD_BLESS, pCreature);
                    break;
                default:
                    break;
                }
            }
            player->CLOSE_GOSSIP_MENU();
            player->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
        }
        return true;
    }
    

    

    
};

class npc_cooshcoosh : public CreatureScript
{
public: 
    npc_cooshcoosh() : CreatureScript("npc_cooshcoosh") { }
    struct npc_cooshcooshAI : public ScriptedAI
    {
        npc_cooshcooshAI(Creature* c) : ScriptedAI(c) {}
    
        uint32 LightningBolt_Timer;
    	uint32 LighningShield_Timer;
    
        void Reset()
        {
            LightningBolt_Timer = 2000;
    		LighningShield_Timer = 25000;
            me->SetFaction(35);
    
    		DoCast(me, SPELL_LIGHTNING_SHIELD);
        }
    
        void EnterCombat(Unit* /*who*/) {}
    
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;
    
    		if (LighningShield_Timer <= diff)
    		{
    			DoCast(me, SPELL_LIGHTNING_SHIELD);
    			LighningShield_Timer = 25000;
    		}
    		else LighningShield_Timer -= diff;
    
            if (LightningBolt_Timer <= diff)
            {
                DoCastVictim(SPELL_LIGHTNING_BOLT);
                LightningBolt_Timer = 5000;
            }
            else LightningBolt_Timer -= diff;
    
            DoMeleeAttackIfReady();
        }
    };

    

     CreatureAI* GetAI(Creature* pCreature) const
    {
        return new npc_cooshcooshAI (pCreature);
    }

    bool OnGossipHello(Player* player, Creature* pCreature) override
    {
        if (player->GetQuestStatus(10009) == QUEST_STATUS_INCOMPLETE)
            player->ADD_GOSSIP_ITEM(0, GOSSIP_COOSH, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
    
        player->SEND_GOSSIP_MENU(9441, pCreature->GetGUID());
        return true;
    }
    

    

    bool OnGossipSelect(Player* player, Creature* pCreature, uint32 /*sender*/, uint32 action) override
    {
        if (action == GOSSIP_ACTION_INFO_DEF)
        {
            player->CLOSE_GOSSIP_MENU();
    		DoScriptText(SAY_COOSH, pCreature);
            pCreature->SetFaction(45);
            ((npc_cooshcooshAI*)pCreature->AI())->AttackStart(player);
        }
        return true;
    }
    

    

    
};

class npc_elder_kuruti : public CreatureScript
{
public: 
    npc_elder_kuruti() : CreatureScript("npc_elder_kuruti") { }
    struct npc_elder_kurutiAI : public ScriptedAI
    {
    	npc_elder_kurutiAI(Creature* pCreature) : ScriptedAI(pCreature) {}
    
    	void Reset()
    	{
    		chainlight_timer = 8000;
    		healingwave_timer = 2000;
    		lightshield_timer = 1000;
    	}
    
    	uint32 chainlight_timer;
    	uint32 healingwave_timer;
    	uint32 lightshield_timer;
    
    	void EnterCombat(Unit* /*who*/) { }
    
    	void UpdateAI(const uint32 uiDiff)
    	{
    		if (!UpdateVictim())
    			return;
    
    		if (chainlight_timer <= uiDiff)
    		{
    			DoCastVictim(SPELL_CHAINLIGHTNING);
    			chainlight_timer = 8000;
    		}
    		else chainlight_timer -= uiDiff;
    
    		if (healingwave_timer <= uiDiff && HealthBelowPct(50))
    		{
    			DoCast(me, SPELL_HEALINGWAVE);
    			healingwave_timer = 12000;
    		}
    		else healingwave_timer -= uiDiff;
    
    		if (lightshield_timer <= uiDiff)
    		{
    			DoCast(me, SPELL_LIGHTNINGSHIELD);
    			lightshield_timer = 15000;
    		}
    		else lightshield_timer -= uiDiff;
    
    		DoMeleeAttackIfReady();
    	}
    };

    

     CreatureAI* GetAI(Creature* creature) const
    {
    	return new npc_elder_kurutiAI(creature);
    }

    bool OnGossipHello(Player* player, Creature* pCreature) override
    {
        if (player->GetQuestStatus(9803) == QUEST_STATUS_INCOMPLETE)
            player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KUR1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
    
        player->SEND_GOSSIP_MENU(9226, pCreature->GetGUID());
    
        return true;
    }
    


    bool OnGossipSelect(Player* player, Creature* pCreature, uint32 /*sender*/, uint32 action) override
    {
        switch (action)
        {
        case GOSSIP_ACTION_INFO_DEF:
            player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KUR2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
            player->SEND_GOSSIP_MENU(9227, pCreature->GetGUID());
            break;
        case GOSSIP_ACTION_INFO_DEF + 1:
            player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KUR3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
            player->SEND_GOSSIP_MENU(9229, pCreature->GetGUID());
            break;
        case GOSSIP_ACTION_INFO_DEF + 2:
            {
                if (!player->HasItemCount(24573, 1))
                {
                    ItemPosCountVec dest;
                    uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 24573, 1, NULL);
                    if (msg == EQUIP_ERR_OK)
                        player->StoreNewItem(dest, 24573, true);
                    else
                        player->SendEquipError(msg, NULL, NULL);
                }
                player->SEND_GOSSIP_MENU(9231, pCreature->GetGUID());
                break;
            }
        }
        return true;
    }
    

    

    
};

class npc_mortog_steamhead : public CreatureScript
{
public: 
    npc_mortog_steamhead() : CreatureScript("npc_mortog_steamhead") { }
    

    

    bool OnGossipHello(Player* player, Creature* pCreature) override
    {
        if (pCreature->IsVendor() && player->GetReputationRank(942) == REP_EXALTED)
            player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
    
        player->SEND_GOSSIP_MENU(player->GetGossipTextId(pCreature), pCreature->GetGUID());
    
        return true;
    }
    


    bool OnGossipSelect(Player* player, Creature* pCreature, uint32 /*sender*/, uint32 action) override
    {
        if (action == GOSSIP_ACTION_TRADE)
            player->SEND_VENDORLIST(pCreature->GetGUID());
        return true;
    }
    

    

    
};

class npc_kayra_longmane : public CreatureScript
{
public: 
    npc_kayra_longmane() : CreatureScript("npc_kayra_longmane") { }
    struct npc_kayra_longmaneAI : public npc_escortAI
    {
        npc_kayra_longmaneAI(Creature* c) : npc_escortAI(c) {}
    
        void Reset() { }
    
        void WaypointReached(uint32 i)
        {
            Player* pPlayer = GetPlayerForEscort();
    
            if (!pPlayer)
                return;
    
            switch (i)
            {
            case 4:
                DoScriptText(SAY_AMBUSH1, me, pPlayer);
                DoSpawnCreature(NPC_SLAVEBINDER, -10.0f, -5.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
                DoSpawnCreature(NPC_SLAVEBINDER, -8.0f, 5.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
                break;
            case 5:
                DoScriptText(SAY_PROGRESS, me, pPlayer);
                SetRun();
                break;
            case 16:
                DoScriptText(SAY_AMBUSH2, me, pPlayer);
                DoSpawnCreature(NPC_SLAVEBINDER, -10.0f, -5.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
                DoSpawnCreature(NPC_SLAVEBINDER, -8.0f, 5.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
                break;
            case 17:
                SetRun(false);
                DoScriptText(SAY_END, me, pPlayer);
                break;
            case 25:
                pPlayer->GroupEventHappens(QUEST_ESCAPE_FROM, me);
                break;
            }
        }
    };

    
     CreatureAI* GetAI(Creature* pCreature) const
    {
        return new npc_kayra_longmaneAI(pCreature);
    }
    

    bool OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* pQuest) override
    {
        if (pQuest->GetQuestId() == QUEST_ESCAPE_FROM)
        {
            DoScriptText(SAY_START, pCreature, pPlayer);
    
            if (npc_escortAI* pEscortAI = CAST_AI(npc_kayra_longmaneAI, pCreature->AI()))
                pEscortAI->Start(false, false, pPlayer->GetGUID());
        }
        return true;
    }
    

    

    
};

class npc_timothy_daniels : public CreatureScript
{
public: 
    npc_timothy_daniels() : CreatureScript("npc_timothy_daniels") { }
    

    

    bool OnGossipHello(Player* pPlayer, Creature* pCreature) override
    {
        if (pCreature->IsQuestGiver())
            pPlayer->PrepareQuestMenu(pCreature->GetGUID());
    
        if (pCreature->IsVendor())
            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_POISONS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
    
        pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TIMOTHY_DANIELS_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
        pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
        return true;
    }
   
    bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction) override
    {
        pPlayer->PlayerTalkClass->ClearMenus();
        switch (uiAction)
        {
        case GOSSIP_ACTION_INFO_DEF+1:
            pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_TIMOTHY_DANIELS1, pCreature->GetGUID());
            break;
        case GOSSIP_ACTION_TRADE:
            pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
            break;
        }
    
        return true;
    }
    

    

    
};

class npc_baby_murloc : public CreatureScript
{
public: 
    npc_baby_murloc() : CreatureScript("npc_baby_murloc") { }
    struct npc_baby_murlocAI : public ScriptedAI
    {
        npc_baby_murlocAI(Creature* creature) : ScriptedAI(creature) {}
    
        uint64 PlayerGUID;
        uint32 CheckTimer;
        uint32 EndTimer;
    
        void Reset()
        {
            PlayerGUID = 0;
            CheckTimer = 7000;
            EndTimer = 15000;
            DoSummon();
            me->GetMotionMaster()->MovePoint(0, M[0].x, M[0].y, M[0].z);
            me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_DANCE);
        }
    
        void DoSummon()
        {
            float x, y, z;
            x = me->GetPositionX();
            y = me->GetPositionY();
            z = me->GetPositionZ();
    
            me->SummonCreature(NPC_PURPLE_MURLOC, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 60000);
            me->SummonCreature(NPC_GREEN_MURLOC , x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 9000);
            me->SummonCreature(NPC_BLUE_MURLOC  , x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 9000);
            me->SummonCreature(NPC_PINK_MURLOC  , x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 9000);
            me->SummonCreature(NPC_ORANGE_MURLOC, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 9000);
        }
    
        void JustSummoned(Creature* summoned)
        {  
            summoned->SetWalk(false);
    
            switch(summoned->GetEntry())
            {
                case NPC_PURPLE_MURLOC:
                    summoned->GetMotionMaster()->MovePoint(0, M[1].x, M[1].y, M[1].z);
                    summoned->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_DANCE);
                    break;
                case NPC_GREEN_MURLOC:
                    summoned->GetMotionMaster()->MovePoint(0, M[2].x, M[2].y, M[2].z);
                    break;
                case NPC_BLUE_MURLOC:
                    summoned->GetMotionMaster()->MovePoint(0, M[3].x, M[3].y, M[3].z);
                    break;
                case NPC_ORANGE_MURLOC:
                    summoned->GetMotionMaster()->MovePoint(0, M[4].x, M[4].y, M[4].z);
                    break;
                case NPC_PINK_MURLOC:
                    summoned->GetMotionMaster()->MovePoint(0, M[5].x, M[5].y, M[5].z);
                    break;
            }
        }
    
        void MoveInLineOfSight(Unit *who)
        {
            if (who->GetTypeId() == TYPEID_PLAYER)
            {
                if (((Player*)who)->GetQuestStatus(QUEST_HAVE_YOU_EVER) == QUEST_STATUS_INCOMPLETE)
                {
                    if (me->IsWithinDistInMap(((Player*)who), 15))
                    {
                        PlayerGUID = who->GetGUID();
                    }
                }
            }
        }
    
        void UpdateAI(const uint32 diff)
        {
            if (CheckTimer <= diff)
            {
                if (Player* player = sObjectMgr.GetPlayer(PlayerGUID))
                {
                    me->SetFacingToObject(player);
                    DoCast(me, SPELL_SING);
    
                    if (Creature* Purple = GetClosestCreatureWithEntry(me, NPC_PURPLE_MURLOC, 20.0f))
                    {
                        Purple->SetFacingToObject(player);
                        Purple->CastSpell(Purple, SPELL_SING, true);
                    }
                }
    
                CheckTimer = 15000;
            }
            else
                CheckTimer -= diff;
    
            if (EndTimer <= diff)
            {
                if (Player* player = sObjectMgr.GetPlayer(PlayerGUID))
                    player->KilledMonsterCredit(NPC_CREDIT, me->GetGUID());;
            }
            else
                EndTimer -= diff;
        }
    };

    

     CreatureAI* GetAI(Creature* creature) const
    {
        return new npc_baby_murlocAI(creature);
    }

    

    
};

class npc_scoutjyoba : public CreatureScript
{
public: 
    npc_scoutjyoba() : CreatureScript("npc_scoutjyoba") { }
    struct npc_scoutjyobaAI : public ScriptedAI
    {
    	npc_scoutjyobaAI(Creature* creature) : ScriptedAI(creature) {}
    
    	void Reset()
    	{
    		me->SetStandState(UNIT_STAND_STATE_DEAD);
    	}
    
    	void UpdateAI(const uint32 diff) { }
    };

    

     CreatureAI* GetAI(Creature* creature) const
    {
    	return new npc_scoutjyobaAI(creature);
    }

    

    
};

class npc_wrektslave : public CreatureScript
{
public: 
    npc_wrektslave() : CreatureScript("npc_wrektslave") { }
    struct npc_wrektslaveAI : public ScriptedAI
    {
    	npc_wrektslaveAI(Creature* pCreature) : ScriptedAI(pCreature) {}
    
    	void Reset()
    	{
    		kick_timer = 8000;
    		flee_timer = 6000;
    		share_timer = 10000;
    
    		me->SetFaction(74);
    		flee = false;
    		say = false;
    	}
    
    	uint32 kick_timer;
    	uint32 flee_timer;
    	uint32 share_timer;
    
    	bool flee;
    	bool say;
    
    	void EnterCombat(Unit* /*who*/) { }
    
    	void UpdateAI(const uint32 uiDiff)
    	{
    		if (!UpdateVictim())
    		{
    			if (flee == true)
    			{
    				me->GetMotionMaster()->MovePoint(1, FleePath, true);
    
    				if (!say)
    				{
    					DoScriptText(SAY_RUN, me);
    					say = true;
    				}
    
    				if (flee_timer <= uiDiff)
    				{
    					me->DisappearAndDie();
    					flee_timer = 4000;
    				}
    				else flee_timer -= uiDiff;
    			}
    		}
    		
    		if (UpdateVictim())
    		{
    			if (kick_timer <= uiDiff)
    			{
    				DoCastVictim(SPELL_KICK);
    				kick_timer = 8000;
    			}
    			else kick_timer -= uiDiff;
    
    			if (me->FindNearestCreature(NPC_SLAVEDRIVER, 25, false))
    			{
    				me->SetFaction(35);
    				me->CombatStop();
    				flee = true;
    			}
    
    			if (Creature* ally = me->FindNearestCreature(NPC_WREKTSLAVE, 10, true))
    			if (share_timer <= uiDiff)
    			{
    				DoCast(ally, SPELL_SHAREDBONDS);
    				share_timer = 20000;
    			}
    			else share_timer -= uiDiff;
    		}
    
    		DoMeleeAttackIfReady();
    	}
    };

    

     CreatureAI* GetAI(Creature* creature) const
    {
    	return new npc_wrektslaveAI(creature);
    }
};

class npc_dreghooddrudge : public CreatureScript
{
public: 
    npc_dreghooddrudge() : CreatureScript("npc_dreghooddrudge") { }
    struct npc_dreghooddrudgeAI : public ScriptedAI
    {
    	npc_dreghooddrudgeAI(Creature* pCreature) : ScriptedAI(pCreature) {}
    
    	void Reset()
    	{
    		flee_timer = 8000;
    		share_timer = 10000;
    
    		me->SetFaction(74);
    		flee = false;
    	}
    
    	uint32 flee_timer;
    	uint32 share_timer;
    
    	bool flee;
    
    	void EnterCombat(Unit* /*who*/) { }
    
    	void UpdateAI(const uint32 uiDiff)
    	{
    		if (!UpdateVictim())
    		{
    			if (flee == true)
    			{
    				me->GetMotionMaster()->MovePoint(1, Flee1Path, true);
    
    				if (flee_timer <= uiDiff)
    				{
    					me->DisappearAndDie(false);
    					flee_timer = 8000;
    				}
    				else flee_timer -= uiDiff;
    			}
    		}
    
    		if (UpdateVictim())
    		{
    			if (me->FindNearestCreature(NPC_DARKSCRESTSLAVER, 25, false))
    			{
    				me->SetFaction(35);
    				me->CombatStop();
    				flee = true;
    			}
    
    			if (Creature* ally = me->FindNearestCreature(NPC_DREGHOODSLAVE, 10, true))
    			if (share_timer <= uiDiff)
    			{
    				DoCast(ally, SPELL_SHAREDBONDS);
    				share_timer = 20000;
    			}
    			else share_timer -= uiDiff;
    		}
    
    		DoMeleeAttackIfReady();
    	}
    };

    

     CreatureAI* GetAI(Creature* creature) const
    {
    	return new npc_dreghooddrudgeAI(creature);
    }
};


void AddSC_zangarmarsh()
{
    new npcs_ashyen_and_keleth();
    new npc_cooshcoosh();
    new npc_elder_kuruti();
    new npc_mortog_steamhead();
    new npc_kayra_longmane();
    new npc_timothy_daniels();
    new npc_baby_murloc();
    new npc_scoutjyoba();
    new npc_wrektslave();
    new npc_dreghooddrudge();

}

